package com.boot.ys.mybatisplus.controller;

import java.security.MessageDigest;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

import com.boot.ys.mybatisplus.utils.DateUtil;
import org.apache.commons.lang3.RandomStringUtils;
import org.joda.time.DateTime;

public class Test {

    public void Test(String name){

    }

    public static void main(String[] args) {


        String str1="abc";
        String str2="abc";
        String str3="ab";
        String str4="c";
        String str5=str3+str4;
        String str6="ab"+"c";
        final String str7="c";
        String str8="ab"+str7;
        System.out.println(str1==str2);
        System.out.println(str1==str5);
        System.out.println(str1==str6);
        System.out.println(str1==str8 );
        System.out.println(str1.equals(str5));




//        Test person1=new Test("zhangsan");
//        Test person2=new Test("zhangsan");
//        person1==person2 ？
//        person1.equals（person2）？



//        String yyyyMMddHHmmssSSS = DateUtil.format(new Date(), "yyyyMMdd");
//        System.out.println("yyyyMMddHHmmssSSS"+yyyyMMddHHmmssSSS);

        //生成随机字符串
//        String s = RandomStringUtils.randomNumeric(2);
//        System.out.println(s);

//        String md5EncodeUtf8 = MD5Util.MD5EncodeUtf8("123456");
//        System.out.print("------------"+md5EncodeUtf8+"----------");

//        Date d = new Date();
//        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
//        String format = sdf.format(d);
//        String mobid = "456";
//        String agree  = mobid + format;
//        System.out.println(agree);

//        int [] arr ;
//        int [] aa = new int[3];
//        aa[0] = 1;
//        aa[1] = 2;
//        aa[2] = 3;
//
//        System.out.println(aa.length);


    }
}


class demo{
    public static String format(Date date, String pattern) {
        if (date == null) {
            return null;
        }
        return new DateTime(date).toString(pattern);
    }
}


 class MD5Util {



    private static String byteArrayToHexString(byte b[]) {
        StringBuffer resultSb = new StringBuffer();
        for (int i = 0; i < b.length; i++)
            resultSb.append(byteToHexString(b[i]));

        return resultSb.toString();
    }

    private static String byteToHexString(byte b) {
        int n = b;
        if (n < 0)
            n += 256;
        int d1 = n / 16;
        int d2 = n % 16;
        return hexDigits[d1] + hexDigits[d2];
    }

    /**
     * 返回大写MD5
     *
     * @param origin
     * @param charsetname
     * @return
     */
    private static String MD5Encode(String origin, String charsetname) {
        String resultString = null;
        try {
            resultString = new String(origin);
            MessageDigest md = MessageDigest.getInstance("MD5");
            if (charsetname == null || "".equals(charsetname))
                resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
            else
                resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname)));
        } catch (Exception exception) {
        }
        return resultString.toUpperCase();
    }

    public static String MD5EncodeUtf8(String origin) {

        //盐值Salt加密
        //origin = origin + PropertiesUtil.getProperty("password.salt", "");
        return MD5Encode(origin, "utf-8");
    }


    private static final String hexDigits[] = {"0", "1", "2", "3", "4", "5",
            "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};

}
